#!/bin/bash
echo "📁 完整工具链目录结构对比分析"
echo "=========================================="

MSYS2_ROOT="/c/msys64"
#! MSYS2_ROOT="/d"
TOOLCHAINS=("mingw32" "mingw64" "ucrt64" "clang64")

analyze_toolchain() {
    local tc="$1"
    local path="$MSYS2_ROOT/$tc"
    
    echo "=== $tc ==="
    if [ -d "$path" ]; then
        echo "目录结构:"
        ls -la "$path" | grep "^d" | awk '{print "   "$9}'
        
        # 统计文件数量
        echo ""
        echo "文件统计:"
        echo "  头文件: $(find "$path/include" -name "*.h" 2>/dev/null | wc -l) 个"
        echo "  库文件: $(find "$path/lib" -name "*.a" -o -name "*.dll.a" 2>/dev/null | wc -l) 个"
        echo "  二进制: $(find "$path/bin" -name "*.exe" -o -name "*.dll" 2>/dev/null | wc -l) 个"
    else
        echo "❌ 目录不存在"
    fi
    echo ""
}

for tc in "${TOOLCHAINS[@]}"; do
    analyze_toolchain "$tc"
done

# 特殊目录分析
echo "🔍 特殊目录分析:"
echo "mingw32 特有的目录:"
ls -la "/c/msys64/mingw32" | grep "^d" | awk '{print $9}' > mingw32_dirs.txt
ls -la "/c/msys64/ucrt64" | grep "^d" | awk '{print $9}' > ucrt64_dirs.txt
comm -23 mingw32_dirs.txt ucrt64_dirs.txt

rm -f mingw32_dirs.txt ucrt64_dirs.txt
